# -*- coding: utf-8 -*-
import io
import sys
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') #改变标准输出的默认编码

import csv
dict_mashup_to_api = {
    "source":"category",
}

with open("mashup_nodes_estimator.csv", encoding='utf-8', mode="r", errors='ignore') as f:
    reader = csv.reader(f)
    for row in reader:
        if row[2] in dict_mashup_to_api:
            dict_mashup_to_api[row[2]] = row[6]
        else:
            dict_mashup_to_api[row[2]] = row[6]

with open('mashup调用api对应的类别.csv', "w", newline='', encoding='utf-8', errors='ignore') as f:
    writer = csv.writer(f)

    with open("m-a_edges.csv", encoding='utf-8', mode="r", errors='ignore') as f:
        reader = csv.reader(f)
        for row in reader:
            if row[0] in dict_mashup_to_api.keys():
                data = [row[0], row[1], dict_mashup_to_api[row[0]]]
                writer.writerow(data)

